package com.shrct.businessprocess.product.impl;

import com.shrct.businessprocess.product.RCIdentifiablePhysicalProductEntry;
import com.shrct.businessprocess.product.RCLogicProduct;
import com.shrct.businessprocess.product.RCProductSpecification;
import com.shrct.businessprocess.product.RCRMAChildrenReplacementEvent;
import com.shrct.businessprocess.product.impl.RCProductSpecificationImpl;
import com.shrct.businessprocess.product.impl.RCRMAEventImpl;
import com.shrct.businessprocess.product.proxy.RCRMAChildrenReplacementEventProxy;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCRMACHILDRENREPLACEMENTEVENT_TYPE")
public class RCRMAChildrenReplacementEventImpl extends RCRMAEventImpl implements RCRMAChildrenReplacementEvent {
  public RCRMAChildrenReplacementEventImpl() {
    super();
  }
  
  public RCRMAChildrenReplacementEventImpl(final RCLogicProduct logicProduct) {
    super( logicProduct);
    
  }
  
  @JoinColumn(name = "type_id")
  @ManyToOne(targetEntity = RCProductSpecificationImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCProductSpecification type;
  
  public RCProductSpecification getType() {
    return this.type;
  }
  
  public RCRMAChildrenReplacementEvent setType(final RCProductSpecification type) {
    this.type = type;
    return this;			
    
  }
  
  public String getEventTitle() {
    return "\u5B50\u8BBE\u5907RMA";
  }
  
  public String getDescription() {
    RCLogicProduct _logicProduct = this.getLogicProduct();
    RCIdentifiablePhysicalProductEntry _currentProduct = _logicProduct.getCurrentProduct();
    String _sid = _currentProduct.getSid();
    String _plus = ("\u5B50\u8BBE\u5907RMA\uFF0C\u7236\u8BBE\u5907:" + _sid);
    String _plus_1 = (_plus + ",\u5B50\u8BBE\u5907\u7C7B\u578B:");
    String _code = this.type.getCode();
    String _plus_2 = (_plus_1 + _code);
    return _plus_2;
  }
  
  public static RCRMAChildrenReplacementEvent create(final RCLogicProduct logicProduct, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.product.RCRMAChildrenReplacementEvent rCRMAChildrenReplacementEvent = new com.shrct.businessprocess.product.impl.RCRMAChildrenReplacementEventImpl(
    	logicProduct
    );
    objectFactory.create(rCRMAChildrenReplacementEvent);
    return rCRMAChildrenReplacementEvent;			
    
  }
  
  public static RCRMAChildrenReplacementEvent createRCRMAChildrenReplacementEventImpl(final RCLogicProduct logicProduct, final IObjectFactory objectFactory, final Procedure1<RCRMAChildrenReplacementEvent> init) {
    com.shrct.businessprocess.product.RCRMAChildrenReplacementEvent rCRMAChildrenReplacementEvent = new com.shrct.businessprocess.product.impl.RCRMAChildrenReplacementEventImpl(
    	logicProduct
    );
    objectFactory.create(rCRMAChildrenReplacementEvent);
    init.apply(rCRMAChildrenReplacementEvent);
    
    return rCRMAChildrenReplacementEvent;			
    
  }
  
  public RCRMAChildrenReplacementEventProxy toProxy() {
    com.shrct.businessprocess.product.proxy.RCRMAChildrenReplacementEventProxy proxy = new com.shrct.businessprocess.product.proxy.RCRMAChildrenReplacementEventProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
